package com.yanggu.scala.chapater07.extend

object TestExtend {

  def main(args: Array[String]): Unit = {
    val student = new Student
    student.study()
  }

}

class Person {

  var name : String = "jack"

  private val sal : Double = 9999.9

  protected  var age = 10

  var job : String = "大数据工程师"

  def showInfo(): Unit = {
    println("name = " + name + ", sal = " + sal + ", job = " + job)
  }

  def printName(): Unit = {
    println(name)
  }

}

class Student extends Person {

  def study(): Unit = {
    println("name = " + name + ", job = " + job)
//    子类无法访问父类的私有属性，因为sal()方法被私有了
//    println(sal)
  }

  override def printName(): Unit = {
    println("子类重写父类的方法")
    println(name)
  }
}

